package com.wb.fegin;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class NacosFeignClientFallbackFactory implements NacosFeignClient {

    private final Logger logger = LoggerFactory.getLogger(NacosFeignClientFallbackFactory.class);

    @Override
    public String echo(String string) {
        String result = "";
        ObjectMapper objectMapper = new ObjectMapper();
        Map<String,String> params = Maps.newHashMap();
        params.put("result" , "发生异常");
        try {
            result = objectMapper.writeValueAsString(params);
        } catch (JsonProcessingException e) {
            logger.error("" , e);
        }
        return result;
    }
}
